package com.belf.web.controller.console;

import com.belf.common.core.controller.BaseController;
import com.belf.common.core.domain.AjaxResult;
import com.belf.console.domain.GenerateDataModel;
import com.belf.console.service.IGenerateSourceDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * ai生成源端数据
 */
@RestController
@RequestMapping("/console/generateSourceData")
public class GenerateSourceDataController extends BaseController {

    @Autowired
    private IGenerateSourceDataService generateSourceDataService;

    @PostMapping("/generate")
    @ResponseBody
    public AjaxResult generate(@RequestBody GenerateDataModel dataInfo)
    {
        try {
            generateSourceDataService.generate(dataInfo);
            generateSourceDataService.createTask(dataInfo);
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
        return AjaxResult.success();
    }

}
